-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document evaluation results table with pagination #300
Document evaluation results table with pagination #300
Conversation
cc39e83
to
1a85bbc
Compare
project: ctx.project, | ||
filterByStatus: input.status, | ||
}) | ||
.$dynamic(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No so bad in the end. We just need to invoke $dynamic()
in our queries and it will be paginated and fully typed
const rows = await query.limit(pageSize).offset((page - 1) * pageSize) | ||
const count = rows[0]?.__count ? Number(rows[0]?.__count) : 0 | ||
return [rows, count] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repositiries are not the right place to put pagination concerns. Now one doubt I have is with the generic Repository.findAll()
. Now it executes the query. I think would be better to return the query and use the paginateQuery
service to let it do the pagination work. I wont do this refactor here
But what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm i think it's weird ideally you want the repository.findall method to return the results not the query, any way we can integrate the pagination into the findall method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm ya, well then yes i would remove the findall method from repositories all together and use the scope plus the new pagination method you created
@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest' | |||
import { mergeCommit } from '../../services/commits' | |||
import { updateDocument } from '../../services/documents' | |||
import * as factories from '../../tests/factories' | |||
import { computeDocumentLogsWithMetadata } from './computeDocumentLogsWithMetadata' | |||
import { computeDocumentLogsWithMetadataQuery } from './computeDocumentLogsWithMetadata' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By convention if a query service return the lazy query call it [something]Query
so we know
2374049
to
1bba8fc
Compare
onSelect={setSelectedTab} | ||
/> | ||
<div className='flex flex-col relative w-full h-full max-h-full max-w-full overflow-auto'> | ||
<div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { workspace } = await getCurrentUser() | ||
const evaluationScope = new EvaluationsRepository(workspace.id) | ||
return evaluationScope.find(id).then((r) => r.unwrap()) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that evaluation is fetched in layout and page is a perfect use case for cache
1bba8fc
to
67f6f25
Compare
const { data: evaluationResults, mutate } = useEvaluationResultsWithMetadata( | ||
{ | ||
evaluationId: evaluation.id, | ||
documentUuid: document.documentUuid, | ||
commitUuid: commit.uuid, | ||
projectId: project.id, | ||
page, | ||
pageSize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess was that because a different page means a different URL all the client is wipe out. But that's not the case and when you move to page 2 you still see cached page 1 in the client. So I did that the store also is aware of pagination in the cache key so whenever change it make a new fetch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be taken into account when we introduce filters in evaluation results table
documentUuid: string | ||
evaluationId: string | ||
} | ||
searchParams: QueryParams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So before this changes everthing was in the layout and create batch modal was route URL. This is not possible because query params (search params) are not revalidated in layouts so I need to convert results table in a page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classic question: is this messing with any modals in subroutes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, create batch was a route and now is not because if we keep as route the table is not visible when open
documentUuid: params.documentUuid, | ||
draft: commit, | ||
}).$dynamic(), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really happy with the final API of paginateQuery
it does 2 things:
- Paginate the SQL query
- Generates a
IPagination
object to be consumed by pagination UI components
}) { | ||
const [selectedTab, setSelectedTab] = useState<string>('metadata') | ||
const ref = useRef<HTMLDivElement>(null) | ||
const height = useDynamicHeight({ ref, paddingBottom: 16 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh man, web apps with scrollable areas are not as easy as doing web pages. I don't care what DHH says
</div> | ||
</div> | ||
)} | ||
{visibleMessages.map((message, index) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hiding messages is gone cc @cesr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why didn't we like this? in evaluations it's useless to see a ultra long conversation chain in a width of 150 pixels
Refactor pagination to make it more generic and easy to use in any table we want to add pagination
67f6f25
to
2e875a1
Compare
@@ -47,7 +47,8 @@ describe('DocumentVersionsRepository', () => { | |||
|
|||
const documents = result.unwrap() | |||
expect(documents).toHaveLength(2) | |||
expect(documents.map((d) => d.path)).toEqual(['foo', 'bar']) | |||
const paths = documents.map((d) => d.path).sort() | |||
expect(paths).toEqual(['bar', 'foo']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Troll test failing in my branch. I didn't touch this
.../[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Chat.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this route now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside ./Actions/**.tsx
component. Now is not a route
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like wat? We have been here before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well it's a pretty uncommon modal so ok this time,but please let's not make it a common thing that we remove modal from routes and into components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also is this so important? What we lost in this specific case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's why i said this
well it's a pretty uncommon modal so ok this time
not super important in this case. But since you ask we lose the ability to directly link to the creation modal if we ever want to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I wrote my message yours was not in the UI. Lo del real time
What?
Paginate document evaluation results and refactor pagination Refactor pagination to make it more generic and easy to use in any table we want to add pagination
Issue
#283
TODO
paginateQuery
methodlib/pagination/*
I left this broken. Start here/logs
and evaluation results need to be scrollableNext PR
paginateQuery